package xing.infrastructure.util;

import xing.infrastructure.data.EntityBase;

import java.util.List;
import java.util.Set;

public class ContainerUtil {
    public static <TEntity extends EntityBase<TKey>,TKey>  TEntity getItemById(List<TEntity> set, TKey id){
        for(EntityBase item :set){
            if(item.getId().equals(id))
                return (TEntity)item;
        }
        return null;
    }
    public static <TEntity extends EntityBase<TKey>,TKey>  TEntity getItemById(Set<TEntity> set, TKey id){
        for(EntityBase item :set){
            if(item.getId().equals(id))
                return (TEntity)item;
        }
        return null;
    }
}